// 初始化
var myApp = new Framework7({
	pushState : false, //关闭url地址显示
	swipePanel : 'left',
	cache : true, //打开ajax页面缓存.
	tapHold : true, //轻触,
	statusbarOverlay : true, //打开沉浸式
	scrollTopOnStatusbarClick : true, //双击顶部 返回顶部
	hideNavbarOnPageScroll : false,	//true，那么当页面向下滚动的时候，导航栏会自动隐藏；向上滚动的时候会自动出现。
	zlverify:true
});

// 全局的Dom7对象
var $$ = Dom7;

// 初始化视图 view-main
//var mainView = myApp.addView('.view-main', {
//  // Because we use fixed-through navbar we can enable dynamic navbar
//  dynamicNavbar: true,
//  domCache:true
//});

var view1 = myApp.addView('#tab1', {
	dynamicNavbar : true,
	hideNavbarOnPageScroll : false,
});

var view2 = myApp.addView('#tab2', {
	dynamicNavbar : true,
});
var view3 = myApp.addView('#tab3', {
	dynamicNavbar : true,
});
var view4 = myApp.addView('#tab4', {
	dynamicNavbar : true,
});
var view5 = myApp.addView('#tab5', {
	dynamicNavbar : true,
});
//路由加载页面
//mainView.router.loadPage('about.html');

//当侧栏的打开动画结束时，事件将被触发
$$('.panel-left').on('opened', function() {
	myApp.alert('Left panel opened!');
	if ($$('body').hasClass('with-panel-left-cover')) {
		//myApp.alert('Left Panel is opened');
	} else {
		//myApp.alert('Left Panel is noopen');
	}
});

//初始化搜索栏
var mySearchbar = myApp.searchbar('.searchbar', {
	searchList : '.list-block-search', //CSS选择器或者列表块的HTML元素来搜索
	searchIn : '.item-title'
});

//Model-alert
$$('.alert-text').on('click', function() {
	myApp.alert('Alert text');
});
$$('.alert-tittle-text').on('click', function() {
	myApp.alert('标题', '文字说明');
});
$$('.alert-tittle-text-callback').on('click', function() {
	myApp.alert('标题', '文字说明', function() {
		myApp.alert('您点击了ok按钮', '标题');
	});
});

// 特定页面的回调
myApp.onPageInit('about', function(page) {
	// 绑定 点击 事件
	$$('.create-page').on('click', function() {
		createContentPage();
	});
});

// Generate dynamic page
var dynamicPageIndex = 0;
function createContentPage() {
	mainView.router.loadContent('<!-- Top Navbar-->' + '<div class="navbar">' + '  <div class="navbar-inner">' + '    <div class="left"><a href="#" class="back link"><i class="icon icon-back"></i><span>Back</span></a></div>' + '    <div class="center sliding">Dynamic Page ' + (++dynamicPageIndex) + '</div>' + '  </div>' + '</div>' + '<div class="pages">' + '  <!-- Page, data-page contains page name-->' + '  <div data-page="dynamic-pages" class="page">' + '    <!-- Scrollable page content-->' + '    <div class="page-content">' + '      <div class="content-block">' + '        <div class="content-block-inner">' + '          <p>Here is a dynamic page created on ' + new Date() + ' !</p>' + '          <p>Go <a href="#" class="back">back</a> or go to <a href="services.html">Services</a>.</p>' + '        </div>' + '      </div>' + '    </div>' + '  </div>' + '</div>');
	return;
}

//滑动删除
myApp.onPageInit('swipeout-content', function(page) {
	//使用seajs
	seajs.use(['./js/swipeout.js'],function(swipeout){
		swipeout.init('id5');
	});
	
});
myApp.onPageInit('cards', function(page) {
	//使用seajs
	seajs.use(['./js/swipeout.js'],function(ajaxs){
		ajaxs.init(1);
	});
	
});
myApp.onPageInit('vueforms',function(page){
	//使用seajs
	seajs.use(['./js/vuefrom.js'],function(vuefrom){
		vuefrom.init(vuefrom);
	});
});
//字符串模板初始化回调
$$(document).on('pageInit', '.page[data-page="template"]', function(e){
	seajs.use(['./js/template.js'], function(tmp){
		tmp.init(e);
	});
});
myApp.onPageInit('form',function(page){
	ac.form({
            area: "#testfrom",   // 验证区域，支持标签，id，class，推荐使用id或者class
            btn: "#btn",
            endSuccess: function () {
                myApp.alert("全部验证成功啦！！！！！！");
            }
        });
});